<template>
<el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__dict">
        <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
            <el-form-item>
                <el-input v-model="dataForm.name" placeholder="请输入商户名称" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.creditCode" placeholder="请输入统一社会信用代码" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.legalPerson" placeholder="请输入企业法人" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.idCard" placeholder="请输入法人身份证号" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="dataForm.phone" placeholder="请输入联系方式" clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-select v-model="dataForm.islandId" placeholder="请选择区域" clearable>
                    <el-option v-for="item in scenicOptions" :key="item.id" :label="item.scenicName" :value="item.id">
                    </el-option>
                </el-select>
            </el-form-item>
            <!-- <el-form-item>
                <el-select v-model="dataForm.status" placeholder="请选择状态" clearable>
                    <el-option v-for="item in status" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item> -->
            <el-form-item>
                <el-button type="primary" @click="getDataList()">{{ $t("query") }}</el-button>
            </el-form-item>
            <!-- <el-form-item>
                <el-button v-if="$hasPermission('hotel:homestay:save')" type="primary" @click="addOrUpdateHandle()">{{ $t("add") }}</el-button>
            </el-form-item> -->
            <el-form-item>
                <el-button v-if="$hasPermission('hotel:homestay::delete')" type="danger" @click="deleteHandle()">{{ $t("deleteBatch") }}</el-button>
            </el-form-item>
        </el-form>
        <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle" style="width: 100%">
            <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
            <el-table-column prop="creditCode" label="统一社会信用代码" header-align="center" align="center" min-width="150"></el-table-column>
            <el-table-column prop="name" label="商户名称" sortable="custom" header-align="center" align="center" :show-overflow-tooltip="true" min-width="120"></el-table-column>
            <el-table-column prop="merchantCategory" label="商户类型" header-align="center" align="center" min-width="120">
                <template slot-scope="scope">
                    {{$getDictLabel('MerchantCategory',scope.row.merchantCategory)}}
                </template>
            </el-table-column>
            <el-table-column prop="legalPerson" label="企业法人" header-align="center" align="center" width="180"></el-table-column>
            <el-table-column prop="idCard" label="法人身份证号" header-align="center" align="center" width="180"></el-table-column>
            <el-table-column prop="islandName" label="区域" header-align="center" align="center" :show-overflow-tooltip="true" min-width="120">
                <!-- <template slot-scope="scope">
                    {{ scope.row.province }}{{ scope.row.city }}{{ scope.row.area
            }}{{ scope.row.street }}{{ scope.row.areaDetail }}</template> -->
            </el-table-column>
            <!-- <el-table-column prop="status" label="状态" header-align="center" align="center" width="180">
                <template slot-scope="scope">
                    {{scope.row.status | delStatus}}
                </template>
            </el-table-column> -->
            <el-table-column prop="phone" label="联系电话" header-align="center" align="center" :show-overflow-tooltip="true" min-width="120"></el-table-column>
            <el-table-column prop="createDate" label="创建时间" header-align="center" align="center" :show-overflow-tooltip="true" min-width="120"></el-table-column>
            <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
                <template slot-scope="scope">
                    <el-button v-if="scope.row.status == 2&&$hasPermission('merchant:info:audit')" type="text" size="small" @click="lookDetail(scope.row.id)">审核</el-button>
                    <el-button type="text" size="small" v-if="$hasPermission('merchant:info:update')" @click="addOrUpdateHandle(scope.row.id)">{{ $t("update") }}</el-button>
                    <el-button type="text" size="small" v-if="$hasPermission('merchant:info:delete')" @click="deleteHandle(scope.row.id)">{{ $t("delete") }}</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle" @current-change="pageCurrentChangeHandle">
        </el-pagination>
        <!-- 弹窗, 新增 / 修改 -->
        <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
        <!-- 详情审核 -->
        <look-detail v-if="lookDetailVisible" ref="lookDetail" @refreshDataList="getDataList"></look-detail>
    </div>
</el-card>
</template>

<script>
var that;
import mixinViewModule from "@/mixins/view-module";
import AddOrUpdate from "./hotel-add-or-update";
import lookDetail from "./hotel-add-or-update2";
export default {
    mixins: [mixinViewModule],
    data() {
        return {
            mixinViewModuleOptions: {
                // getDataListURL: "/scenic/fisherman/page",
                getDataListURL: "/scenic/merchant/info/page",
                getDataListIsPage: true,
                // deleteURL: "/scenic/fisherman",
                deleteURL: "/scenic/merchant/info",
                deleteIsBatch: true,
                // exportURL: '/scenic/fisherman/export'
            },
            scenicOptions: [],
            status: [{
                    label: "审核未通过",
                    value: 4,
                },
                {
                    label: "审核通过",
                    value: 1,
                },
                {
                    label: "待审核",
                    value: 2,
                },
            ],
            dataForm: {
                idCard: '',
                legalPerson: '',
                islandId: '',
                tradeArea: "",
                merchantCategory: '',
                name: "",
                phone: "",
                status: 2
            },

        };
    },
    created() {
        that = this;
    },
    filters: {
        delStatus(val) {
            if (val) {
                let d = that.status.filter((item) => item.value == val);
                if (d.length != 0) {
                    return d[0].label;
                }
            }
        }
    },
    components: {
        AddOrUpdate,
        lookDetail
    },
    created() {
        this.getScenicOptions();
    },
    methods: {
        getScenicOptions() {
            this.$http
                .get("scenic/isscenic/selectScenicList", {})
                .then(({
                    data: res
                }) => {
                    if (res.msg == "success") {
                        this.scenicOptions = res.data;
                    }
                });
        },
    },
};
</script>
